<?php
session_start();

if(!isset($_SESSION['id'])){
	header('Location:login.php');
}
/*	$licesneid=$_POST['licesneid'];
	$beizhu=$_POST['beizhu'];
	$id=$_POST['id'];
	$typeid=$_POST['typeid'];

	$connect=mysql_connect('localhost','root','');
	mysql_select_db('shenji',$connect);
	mysql_query("set names utf8");
	//session_start();
	$realname=$_SESSION['name'];
	$sql="update jiekou set licesneid='$licesneid',beizhu='$beizhu',typeid='$typeid' where id='$id'";
	mysql_query($sql);
	echo "<script>location='select_jiekou.php';</script>";*/
	if(isset($_POST['submit'])){
	$id=$_POST['id'];
	$licesneid=trim($_POST['licesneid']);
	$beizhu=trim($_POST['beizhu']);
	$typeid=$_POST['typeid'];
	
	if($licesneid==""||$beizhu==""){
		echo "<script>alert('机器码、备注不能为空！');history.go(-1);</script>";
	}elseif(!preg_match("/^[\x{4e00}-\x{9fa5}A-Za-z0-9]{3,32}+$/u", $licesneid)){
		echo "<script>alert('机器码由中文、英文、数字组成！');history.go(-1);</script>";
	}elseif(!preg_match("/^[\x{4e00}-\x{9fa5}A-Za-z0-9.:]{3,32}+$/u", $beizhu)){
		echo "<script>alert('备注由中文、英文、数字组成！');history.go(-1);</script>";
	}else{
		$db=new PDO("mysql:host=localhost;dbname=shenji","root","");
		$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
		$db->query("set names utf8");
		$result=$db->exec("update jiekou set licesneid='$licesneid',beizhu='$beizhu',typeid='$typeid' where id='$id'");
	}
	echo "<script>location='select_jiekou.php';</script>";
}
?>